//
//  main.c
//  c_struct_prfun
//
//  Created by chenyh on 2021/1/18.
//

#include <stdio.h>
#define FUNDLEN 50

struct funds {
    char bank[FUNDLEN];
    double bankfund;
    char save[FUNDLEN];
    double savefund;
};

double sum(const struct funds *);//参数是一个指针
double sum1(struct funds moolah);//参数是一个结构
int main(int argc, const char * argv[]) {
    // insert code here...
    
    struct funds stan = {
        "Garlic-Melon Bank",
        4032.27,
        "Lucky's Savings and Loan",
        8534.94
    };
    
    printf("Stan has a total of $%.2f.\n",sum(&stan));
    printf("Stan has a total of $%.2f.\n",sum1(stan));
    return 0;
}

//两个double类型的数相加
double sum(const struct funds * money) {
    return (money->bankfund + money->savefund);
}

double sum1(struct funds moolah) {
    return (moolah.bankfund + moolah.savefund);
}
